Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C# Fix issues with socket buffer sizes #276

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

chadrockey
Copy link

Attempt for #257 @joseph-henry

@chadrockey
Copy link
Author

I added another commit since it's so near by. Turns out the C# garbage collector can move the byte[] memory and that the unsafe memory call must always be accompanied by pinning the memory so the garbage collector knows not to move that block.

See the comment on this documentation: https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.marshal.unsafeaddrofpinnedarrayelement?view=net-8.0

The likely symptoms are that the memory returned is suddenly all zeroes if it's been cleared or that suddenly the memory turns from expected values to zeroes for the rest of the data. I did not see a situation where it was moved to random or non-zeroed memory.

I believe it's ok to call this multiple times and here rather than in the user code, but I'm not quite sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant